<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/rotate-image/
      思路：https://leetcode-cn.com/problems/rotate-image/solution/zhao-gui-lu-jie-jue-fa-by-malenconiaprincep/
     */
    function rotate(matrix) {
      let len = matrix.length;

      for (let i = 0; i < len; i++) {
        for (let j = i; j < len; j++) {
          let temp = matrix[i][j];
          matrix[i][j] = matrix[j][i];
          matrix[j][i] = temp;
        }
      }

      return matrix.map(item => item.reverse());
    }
  </script>
</body>
</html>